package Test;


import java.util.Arrays;

public class 构建平衡二叉树 {
    public TreeNode sortedArrayToBT(int[] nums) {
         return helper(nums,0,nums.length);

    }
   TreeNode helper(int[] nums,int left,int right){
        if(left>right){
            return null;
        }
        int mid=(right-left)/2+left;
        TreeNode root=new TreeNode(nums[mid]);
        root.left=helper(nums,left,mid-1);
        root.right=helper(nums,mid+1,right);
        return root;
    }
}